//1.导入vue-router的函数
import { createRouter, createWebHashHistory } from 'vue-router'

//2. 导入需要跳转的页面组件.
import NewsFrame from '@/views/News/NewsFrame'
import NewsLogin from '@/views/Login/NewsLogin'
import GLLogin from '@/views/Login/GLLogin'
import NewsRegistry from '@/views/Registry/NewsRegistry'
import PersonFrame from '@/views/person/PersonFrame'
import ListOne from '@/views/News/List/ListOne'
import PublishMGMT from '@/views/publish/PublishMGMT'
import SpaceFrame from '@/views/space/SpaceFrame'
import NewsCollect from '@/views/space/NewsCollect'
import NoteDetail from '@/views/Note/NoteDetail'
import EditMGMT from '@/views/Edit/EditMGMT'
import CommentMGMT from '@/views/Comment/CommentMGMT'

//3. 使用一个数组，定义路由规则
// 每个路由都需要映射到一个组件。
const routes = [
    { path : '/', 
      name : '站点首页',
      component: NewsFrame,
      hidden: true,
      redirect: '/listnoe/1',
      perimission: ['admin', "user"],
      children: [
        {
          path: 'listnoe/:categoryId',
          name: '新闻列表',
          component: ListOne,
          props: true,
          perimission: ['admin', "user"]
        }
      ]
      
    },
    { path : '/login', hidden: true, component: NewsLogin, perimission: ['admin', "user"] },
    { path : '/gllogin' ,hidden: true, component: GLLogin,perimission: ['admin', "user"], },
    { path : '/registry' ,hidden: true, component: NewsRegistry,perimission: ['admin', "user"], },
    { path : '/person' ,hidden: true, component: PersonFrame,perimission: ['admin', "user"], },
    { path : '/space', hidden: true, component: SpaceFrame,perimission: ['admin', "user"]},
    { path : '/collect', hidden: true, component: NewsCollect,perimission: ['admin', "user"]},
    { path : '/detail', hidden: true, component: NoteDetail,perimission: ['admin', "user"]},
    
    { 
      path : '/publish' , 
      component: PublishMGMT, 
      hidden: true,
      perimission: ['admin']
    },{
      path : '/editmgmt',
      component: EditMGMT,
      hidden:true,
      perimission: ['admin']
    },{
      path : '/comment',
      component: CommentMGMT,
      hidden:true,
      perimission: ['admin']
    }
    
]

// 4. 创建Vue-router实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
    // 5. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    routes, // 传入routes数组，这一行是简写，是routes: routes的缩写
})

//6.默认导出创建好的Vue-router的实例
export default router;